package breadfactory.stock.service;

import java.sql.SQLException;
import java.util.ArrayList;

import board.util.Utilities;
import breadfactory.stock.dao.MaterialStockDAO;
import breadfactory.stock.dto.MaterialStockDTO;



public class MaterialStockService {
private MaterialStockDAO dao;
	
	public MaterialStockService(MaterialStockDAO dao){
		this.dao = dao;
	}

	public ArrayList getSelectAllMaterialStockService() {
		ArrayList<MaterialStockDTO> list = dao.getSelectAllMaterialStockDAO();
		for (MaterialStockDTO mdto : list) {
			mdto.setPurchaseDate(board.util.Utilities.changeDayTimeFormat(mdto.getPurchaseDate()));
		}
		System.out.println("service"+list);
		return list;
	}
	public int getSelectKindTotalService(String code) throws SQLException{
	
		return dao.getSelectKindTotal(code);
	}
	public void writeContent(MaterialStockDTO mdto) throws SQLException {
		
		String purchaseDate = Utilities.getNow();	
		mdto.setPurchaseDate(purchaseDate);	
	
		dao.insertContent(mdto);
	}
}
